// 绘制三次贝塞尔曲线
import BaseElement from './element';
class Bezier extends BaseElement {
    constructor(opts) {
        super(opts);
    }

    draw(ctx) {
        this.beforDraw(ctx);

        let { x: x1, y: y1 } = this.points[0];
        let { x: x2, y: y2 } = this.points[1];
        let { x: x3, y: y3 } = this.points[2];
        let { x: x4, y: y4 } = this.points[3];

        if (parseInt(x1) === parseInt(x2)) {
            x1 = x2 = parseInt(x1) + this.offset;
            x3 = parseInt(x3) + this.offset;
            x4 = parseInt(x4) + this.offset;
        } else {
            y1 = parseInt(y1) + this.offset;
            y2 = parseInt(y2) + this.offset;
            y3 = parseInt(y3) + this.offset;
            y4 = parseInt(y4) + this.offset;
        }

        if (this.beginPath) {
            ctx.moveTo(x1, y1);
        }
        ctx.bezierCurveTo(x3, y3, x4, y4, x2, y2);

        this.afterDraw(ctx);
    }

    addPoint() {}
    update() {}
}
export default Bezier;
